package com.ruoyi.ade.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ade.domain.AdeCase;
import com.ruoyi.ade.service.IAdeCaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Ade CasesController
 * 
 * @author wxh
 * @date 2025-06-16
 */
@RestController
@RequestMapping("/ade/case")
public class AdeCaseController extends BaseController
{
    @Autowired
    private IAdeCaseService adeCaseService;

    /**
     * 查询Ade Cases列表
     */
    @PreAuthorize("@ss.hasPermi('ade:case:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdeCase adeCase)
    {
        startPage();
        List<AdeCase> list = adeCaseService.selectAdeCaseList(adeCase);
        return getDataTable(list);
    }

    /**
     * 导出Ade Cases列表
     */
    @PreAuthorize("@ss.hasPermi('ade:case:export')")
    @Log(title = "Ade Cases", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdeCase adeCase)
    {
        List<AdeCase> list = adeCaseService.selectAdeCaseList(adeCase);
        ExcelUtil<AdeCase> util = new ExcelUtil<AdeCase>(AdeCase.class);
        util.exportExcel(response, list, "Ade Cases数据");
    }

    /**
     * 获取Ade Cases详细信息
     */
    @PreAuthorize("@ss.hasPermi('ade:case:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(adeCaseService.selectAdeCaseById(id));
    }

    /**
     * 新增Ade Cases
     */
    @PreAuthorize("@ss.hasPermi('ade:case:add')")
    @Log(title = "Ade Cases", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdeCase adeCase)
    {
        adeCase.setCreateBy(getUsername());
        return toAjax(adeCaseService.insertAdeCase(adeCase));
    }

    /**
     * 修改Ade Cases
     */
    @PreAuthorize("@ss.hasPermi('ade:case:edit')")
    @Log(title = "Ade Cases", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdeCase adeCase)
    {
        adeCase.setUpdateBy(getUsername());
        return toAjax(adeCaseService.updateAdeCase(adeCase));
    }

    /**
     * 删除Ade Cases
     */
    @PreAuthorize("@ss.hasPermi('ade:case:remove')")
    @Log(title = "Ade Cases", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adeCaseService.deleteAdeCaseByIds(ids));
    }
}
